#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<string>
using namespace std;

int main(int argc,char* argv[])
{
    if(argc != 4)
    {
        cout<<"./test2 a b c"<<endl;
        exit(1);
    }

    FILE* a=fopen(argv[1],"r");
    string s;
    char ch;

    while((ch=fgetc(a)) != EOF)
    s+=ch;

    FILE* b=fopen(argv[2],"w+");
    FILE* c=fopen(argv[3],"a");
    
    rewind(b);
    fwrite(s.c_str(),sizeof(char),s.size(),b);
    fwrite(s.c_str(),sizeof(char),s.size(),c);

    fclose(a);
    fclose(b);
    fclose(c);

    return 0;
}
